package com.space.school.dao.impl;

import com.space.school.dao.OITDao;
import com.space.school.domain.Master;
import com.space.school.domain.User;
import com.space.school.utils.SpaceJDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class OITDaoImpl implements OITDao {
    private JdbcTemplate jdbcTemplate=new JdbcTemplate(SpaceJDBCUtils.getDataSource());

    @Override
    public List<Master> findAll() {
        String sql = "select * from order_master";
        return jdbcTemplate.query(sql, new BeanPropertyRowMapper<Master>(Master.class));
    }

    @Override
    public void delete(String order_id) {
        String sql = "delete from order_master where order_id=?";
        jdbcTemplate.update(sql,order_id);
    }

    @Override
    public List<Master> findByOrder_id(String order_id) {
        String sql = "select * from order_master where order_id=?";
        return jdbcTemplate.query(sql, new BeanPropertyRowMapper<Master>(Master.class),order_id);
    }
}
